package com.aaa.web.controller.permissioncontroller;

import com.aaa.entity.Employee;
import com.aaa.entity.Per;
import com.aaa.entity.Permission;
import com.aaa.util.EmpUtil;
import com.aaa.web.commons.EmpQuery;
import com.aaa.web.commons.Result;
import com.aaa.web.service.ipermissionservice.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;
import java.util.Map;
/**
* @program:
* @description:
* @author:
* @create:
**/
@Controller
@RequestMapping("/per")
public class PermissionController {

    @Autowired
    private IPermissionService iPermissionService;
    /**
     * 主入口页面
     */
    @RequestMapping("/getPer")
    public String getPer(Model model){
        List<Permission> permissionList = iPermissionService.getAllPermission();
        model.addAttribute("list",permissionList);
        String name = EmpUtil.getEmp().getName();
        model.addAttribute("employee",name);
        return "views/webhtml/index";
    }

    /**
     * 待办事项页面
     * @return
     */
    @RequestMapping("getConsole")
    public String getConsole(){
        return "views/home/console";
    }

    @RequestMapping("/goPermission")
    public String goPermission(){

        return "views/webhtml/employee/permission";
    }

    @RequestMapping("/getPermission")
    @ResponseBody
    public List<Map> getPermission(EmpQuery query) {

        return iPermissionService.getPermission(query);
    }

    @RequestMapping("/updatePerState")
    @ResponseBody
    public Result updatePerState(Integer id) {
        Result result = iPermissionService.updatePerState(id);
        return result;
    }
    @RequestMapping("/editPer")
    @ResponseBody
    public Result editPer(Permission permission) {
        Result result = iPermissionService.editPer(permission);
        return result;
    }

}
